<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送范围管理</title>
<!-- 引入easyui 的主题样式  和  easyui 提供的图标样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<!-- 引入jquery 和  easyui.js   中文设置js-->
<script type="text/javascript"
	src="${pageContext.request.contextPath}\js\jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">


$(function(){

$('#dg').datagrid({    
    url:'getDSByUid',    
    columns:[[
        {field : 'ck',width : 100,checkbox : true},     
        {field:'dsId',title:'配送范围编号',width:100,align:'center'},    
        {field:'dpName',title:'配送点',width:100,align:'center'},    
        {field:'dsName',title:'配送范围',width:250,align:'center'},   
        {field:'dsDate',title:'配送时间',width:100,align:'center'},   
        {field:'dsRemarks',title:'备注',width:400},  
    ]]  ,
rownumbers : true,
pagePosition : 'bottom',
pagination : true,
pageSize : 10,
pageList : [ 5, 10, 15 ],
toolbar: [{
	iconCls: 'icon-add',
	text:"增加配送范围",
	handler: function(){
		$("#addds").window('open');
	}
},'-',{
	iconCls: 'icon-edit',
	text:"更新配送范围",
	handler: function(){
		var ds = $("#dg").datagrid("getChecked");
		if (ds.length==1) {
		$('#updateds').window("open");
			$('#dsId1').textbox({    
			    value: ds[0].dsId,     
			})
			$('#dpName1').combobox({
					value: ds[0].dpName,  
				})
			$('#dsName1').textbox({    
			    value: ds[0].dsName,     
			})
			$('#dsRemarks').textbox({    
			    value: ds[0].dsRemarks,     
			})
		}else{
			$.messager.alert('警告','请选择一行！');  
		}
	}
}]
});


//增加窗口
$('#addds').window({
	width : 600,
	height : 400,
	modal : true,
	title : "增加",
	collapsible : false,
	minimizable : false,
	maximizable : false,
	closable : false,
	closed : true
});

//配送点
$('#dpName').combobox({    
    url:'findDpByUid',    
    valueField:'dpId',    
    textField:'dpName',
    editable:false,
}); 

//配送范围
$('#dsName').textbox({
	required:true,
});
$('#dsRemarks').textbox({
	multiline:true
});


//文本框光标离开事件
$("input",$("#dsName").next("span")).blur(function(){  
	var dsName = $('#dsName').val();		
	var dpName = $('#dpName').combobox('getValue');		
    $.ajax({		    
    	type:'post',
    	url:'validateAddDs',
    	data:{'dsName' : dsName,
			  'dpId' : dpName
			  },
    	dataType:'text',
    	success:function(data){
    	
    		if (data==1) {
    			$.messager.alert('警告','该配送范围已存在！');      		
			}else{
				$.messager.alert('消息','该配送范围可添加！');  	
		}
   	}
    })
})
//增加确定按钮
$('#adddsyes').linkbutton({
	onClick : function() {
		var dsName = $('#dsName').val();
		var dsRemarks = $('#dsRemarks').val();		
		var dpName = $('#dpName').combobox('getValue');
		var dsDatestart = $('#dsDatestart').combobox('getValue');
		var dsDatestop = $('#dsDatestop').combobox('getValue');
		$.ajax({
			url : 'insertDS',
			type : 'post',
			data : {
				'dsName' : dsName,
				'dsRemarks' : dsRemarks,
				'dpId' : dpName,				
				'dsDatestart' : dsDatestart,				
				'dsDatestop' : dsDatestop,				
			},
			detaType : 'text',
			success : function(data) {
	
				if (data == 1) {
					$("#dg").datagrid('reload');
					$.messager.alert('消息','增加成功'); 
				} else {
					$.messager.show({
						title : '信息提示',
						msg : '增加失败',
						timeout : 1000,
						showType : 'slide'
					});
				}
			}
		});
		$('#addds').window("close");
	}
});
//增加取消
$('#adddsno').linkbutton({
	onClick : function() {
		$('#addds').window("close");
	}
});


//修改窗口
$('#updateds').window({
	width : 600,
	height : 450,
	modal : true,
	title : "修改",
	collapsible : false,
	minimizable : false,
	maximizable : false,
	closable : false,
	closed : true
});

$('#dsId1').textbox({
	readonly:true
});
$('#dpName1').combobox({    
    
    readonly:true
});
$('#dsName1').textbox({
});

//修改确定按钮
$('#updatedsyes').linkbutton({
	onClick : function() {
		$('#updateds').window("close");	
		
		$.ajax({
			url : 'updateDs',
			type : 'post',
			data : {
				'dsId':$("#dsId1").val(),
				'dsName' : $("#dsName1").val(),
				'dsRemarks' : $("#dsRemarks").val(),
				'dsDatestart' : $('#dsDatestart1').combobox('getValue'),
				'dsDatestop' : $('#dsDatestop1').combobox('getValue'),
			},
			dataType : 'text',
			success : function(data) {
				
				if (data == 1) {
					$("#dg").datagrid('reload');
					$.messager.alert('消息','修改成功');  
				} else {
					$.messager.show({
						title : '信息提示',
						msg : '修改失败',
						timeout : 1000,
						showType : 'slide'
					});
				}

			}
		});
	}
});
//修改取消
$('#updatedsno').linkbutton({
	onClick : function() {
		$('#updateds').window("close");
		$("#dg").datagrid('uncheckAll')
	}
});


});
</script>
<body>
<table id="dg"></table>


<!-- 增加窗口 -->

	<div id="addds">
		
<div style="margin-left: 30px; margin-top: 50px">
		
			 <span>配送点：</span>&nbsp;&nbsp;&nbsp;<input id="dpName" type="text" style="width: 200px; height: 32px"> 
			 <span>配送范围：</span><input id="dsName" type="text" style="width: 200px; height: 32px"><br><br>
			<span>开始时间：</span><select id="dsDatestart" class="easyui-combobox" name="dept" style="width: 200px; height: 32px">   
    			<option >00:00</option>   <option>01:00</option>    <option>02:00</option>   
    			<option>03:00</option>    <option>04:00</option>    <option>05:00</option>
    			<option>06:00</option>    <option>07:00</option>    <option>08:00</option>
    			<option>09:00</option>    <option>10:00</option>    <option>11:00</option>
    			<option>12:00</option>    <option>13:00</option>    <option>14:00</option>
    			<option>15:00</option>    <option>16:00</option>    <option>17:00</option>
    			<option>18:00</option>    <option>19:00</option>    <option>20:00</option>
    			<option>21:00</option>    <option>22:00</option>    <option>23:00</option>
			</select>
				<span>结束时间：</span><select id="dsDatestop" class="easyui-combobox" name="dept" style="width: 200px; height: 32px">   
    			<option >00:00</option>   <option>01:00</option>     <option>02:00</option>   
    			<option>03:00</option>    <option>04:00</option>    <option>05:00</option>
    			<option>06:00</option>    <option>07:00</option>    <option>08:00</option>
    			<option>09:00</option>    <option>10:00</option>    <option>11:00</option>
    			<option>12:00</option>    <option>13:00</option>    <option>14:00</option>
    			<option>15:00</option>    <option>16:00</option>    <option>17:00</option>
    			<option>18:00</option>    <option>19:00</option>    <option>20:00</option>
    			<option>21:00</option>    <option>22:00</option>    <option>23:00</option>
			</select>
			<br><br>
			 <span>备注：</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="dsRemarks" type="text" style="width: 450px; height: 100px"><br><br>
				
				 <a id="adddsyes" href="#" iconCls="icon-ok"
				style="width: 90px; height: 32px;margin-left: 150px">确定</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<a id="adddsno" href="#"
				iconCls="icon-no" style="width: 90px; height: 32px">取消</a>

		</div>
	</div>
	
	
	<!-- 修改窗口 -->

	<div id="updateds">
		
<div style="margin-left: 30px; margin-top: 50px">
		
		<span>配送范围编号：</span><input id="dsId1" type="text" style="width: 180px; height: 32px"> <br><br>
			 <span>配送点：</span>&nbsp;&nbsp;&nbsp;<input id="dpName1" type="text" style="width: 200px; height: 32px"> 
			 <span>配送范围：</span><input id="dsName1" type="text" style="width: 200px; height: 32px"><br><br>
			<span>开始时间：</span><select id="dsDatestart1" class="easyui-combobox" name="dept" style="width: 200px; height: 32px">   
    			<option >00:00</option>   <option>01:00</option>    <option>02:00</option>   
    			<option>03:00</option>    <option>04:00</option>    <option>05:00</option>
    			<option>06:00</option>    <option>07:00</option>    <option>08:00</option>
    			<option>09:00</option>    <option>10:00</option>    <option>11:00</option>
    			<option>12:00</option>    <option>13:00</option>    <option>14:00</option>
    			<option>15:00</option>    <option>16:00</option>    <option>17:00</option>
    			<option>18:00</option>    <option>19:00</option>    <option>20:00</option>
    			<option>21:00</option>    <option>22:00</option>    <option>23:00</option>
			</select>
				<span>结束时间：</span><select id="dsDatestop1" class="easyui-combobox" name="dept" style="width: 200px; height: 32px">   
    			<option >00:00</option>   <option>01:00</option>     <option>02:00</option>   
    			<option>03:00</option>    <option>04:00</option>    <option>05:00</option>
    			<option>06:00</option>    <option>07:00</option>    <option>08:00</option>
    			<option>09:00</option>    <option>10:00</option>    <option>11:00</option>
    			<option>12:00</option>    <option>13:00</option>    <option>14:00</option>
    			<option>15:00</option>    <option>16:00</option>    <option>17:00</option>
    			<option>18:00</option>    <option>19:00</option>    <option>20:00</option>
    			<option>21:00</option>    <option>22:00</option>    <option>23:00</option>
			</select>
			<br><br>
			 <span>备注：</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="dsRemarks" type="text" style="width: 450px; height: 100px"><br><br>
				
				 <a id="updatedsyes" href="#" iconCls="icon-ok"
				style="width: 90px; height: 32px;margin-left: 150px">确定</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<a id="updatedsno" href="#"
				iconCls="icon-no" style="width: 90px; height: 32px">取消</a>

		</div>
	</div>
	
	
</body>
</html>